<div class="sm-pop">
    <table id="list_table" class="layui-hide" lay-filter="mainList"></table>
</div>
<script>
    $(function () {
        layui.use(['layer', 'table', "laydate"], function () {
            var upload=layui.upload;
            var layer = layui.layer;
            var table = layui.table;
            var laydate = layui.laydate;

            var tableObj;
            //日期选择
            laydate.render({
                elem: '#video_time',
                range: true,
                done: function (value, date, endDate) {
                    if (value) {
                        $("#list_form input[name='start']").val(value.substring(0, 10));
                        $("#list_form input[name='end']").val(value.substring(13));
                    } else {
                        $("#list_form input[name='start']").val("");
                        $("#list_form input[name='end']").val("");
                    }
                }
            });

            var player = null;

            smartAui.loadCss("/js/plugin/video-js/video-js.css");
            smartAui.loadJs("/js/plugin/video-js/video.js", function () {

            });
            var tableObj = table.render({
                id: 'list_table',
                elem: '#list_table',
                url: '/mediaFile/list?mediaType=video',
                align: "center",
                cols: [[
                    {type: 'checkbox'},
                    {type: 'numbers', title: '序号', width: 50},
                    {field: 'title', title: '标题', width: 150, align: 'center',},
                    {field: 'createTime', title: '上传时间', align: 'center',},
                    {
                        field: 'lock', title: '操作', width: 250, align: 'center', templet: function (d) {
                        return '<a class="font-danger" lay-event="play" href="javascript:;"><i class="iconfont icon-bofang"></i> 预览</a>'
                            + '<a class="font-danger" lay-event="" href="'+d.uploadUrl+'" download="'+d.uploadUrl.substring(d.uploadUrl.lastIndexOf('/')+1)+'" ><i class="iconfont icon-icondownload"></i> 下载</a>'
                            + '<a class="font-primary" lay-event="del" href="javascript:;">删除</a>';
                    }, unresize: true, align: 'center'
                    }
                ]],
            });

            //表格内部操作按钮监听
            table.on('tool(mainList)', function (obj) {
                var data = obj.data;
                var layEvent = obj.event;

                if (layEvent === 'play') {
                    popvideo(data.uploadUrl);
                }
            });
        });
    });
</script>